@extends('backend::layout')
@section('title',$page_title)
@section('content')
    @component('backend::component.form.form')
        @slot('page_title') {{$page_title}} @endslot
        @slot('formId') account @endslot
        @slot('action') {{route('b_Account_correctAccount')}} @endslot


        @component('backend::component.form.form-group')
            @slot('title') 会员账号 @endslot
            @component('backend::component.form.input-group')
                @slot('input')
                    @component('backend::component.form.input')
                        @slot('name') user_number @endslot
                        @slot('value') {{$user_number ?? ''}} @endslot
                    @endcomponent
                @endslot
                @slot('button')
                    @component('backend::component.form.button')
                        @slot('title') 检测账户 @endslot
                        @slot('size') sm @endslot
                        @slot('attr') id=check-user data-target=user_number @endslot
                    @endcomponent
                @endslot
            @endcomponent
            @slot('remark') <span id="user-tips"></span>@endslot
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 校正数量 @endslot
            @component('backend::component.form.input')
                @slot('name') correct_number @endslot
            @endcomponent
        @endcomponent

        @component('backend::component.form.form-group')
            @slot('title') 校正账户 @endslot
            <div>
                @foreach($currency as $value=>$title)
                    @component('backend::component.radio')
                        @slot('title') {{$title}} @endslot
                        @slot('name') account @endslot
                        @slot('value') {{$value}} @endslot
                    @endcomponent
                @endforeach
            </div>
        @endcomponent
        @component('backend::component.form.form-group')
            @slot('title') 校正方式 @endslot
            <div>
                @foreach([0=>'扣除',1=>'增加'] as $value=>$title)
                    @component('backend::component.radio')
                        @slot('title') {{$title}} @endslot
                        @slot('name') correct_type @endslot
                        @slot('value') {{$value}} @endslot
                        @if($value == 0)
                            @slot('checked') checked @endslot
                        @endif
                    @endcomponent
                @endforeach
            </div>
        @endcomponent
        @slot('buttons')
            @component('backend::component.form.button')
                @slot('title') 提交 @endslot
                @slot('size') sm @endslot
                @slot('params') {"formId":"#account"} @endslot
                @slot('class') btn-min-width ajax-form @endslot
            @endcomponent
            @component('backend::component.form.button')
                @slot('title') 重置 @endslot
                @slot('type') reset @endslot
                @slot('size') sm @endslot
                @slot('color') danger @endslot
                @slot('class') btn-min-width @endslot
            @endcomponent
        @endslot
    @endcomponent
@endsection
@push('scripts')
    <script>
        layui.use(['jquery'], function(){
            var $ = layui.jquery;
            $('#check-user').off('click').on('click',function () {
                var targetIpt = $('input[name="'+$(this).data('target')+'"]');
                if(targetIpt.val() == ''){
                    $('#user-tips').text('请输入会员账号');
                    return false;
                }
                $.get("{{route('b_User_getUserInfo')}}",{"user":targetIpt.val()},function (response) {
                    if(!response.status){
                        $('#user-tips').text('会员不存在');
                        return false;
                    }else{
                        $('#user-tips').text(response.data.real_name);
                        return true;
                    }
                })
            });
        });
    </script>
@endpush